package com.wishu.finance.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wishu.finance.domain.ResponseDetailCompanyInfoDto;
import com.wishu.finance.domain.ResponseTMCompanyAccountDetailDto;
import com.wishu.finance.domain.TbBusiness;
import com.wishu.finance.mapper.TCwReceiptPlanMapper;
import com.wishu.finance.mapper.TMCompanyAccountDetailMapper;
import com.wishu.finance.mapper.TbBusinessMapper;
import com.wishu.finance.service.TbBusinessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 25813
 * @description 针对表【tb_business(商户表)】的数据库操作Service实现
 * @createDate 2023-05-04 11:15:40
 */
@Service
public class TbBusinessServiceImpl extends ServiceImpl<TbBusinessMapper, TbBusiness>
        implements TbBusinessService {

    @Resource
    TCwReceiptPlanMapper tCwReceiptPlanMapper;

    @Resource
    TMCompanyAccountDetailMapper tmCompanyAccountDetailMapper;

    @Override
    public ResponseDetailCompanyInfoDto detailCompanyInfo(Long businessId) {
        // 查询账户基本信息
        ResponseDetailCompanyInfoDto detailInfo = baseMapper.detailCompanyInfo(businessId);
        if (detailInfo != null) {
            // 需还款金额
            detailInfo.setNeedPayBack(tCwReceiptPlanMapper.getNeedPaybackMoney(businessId));
            // 查询账户绑定银行卡信息
            List<ResponseTMCompanyAccountDetailDto> accountDetailList = tmCompanyAccountDetailMapper.getAccountDetailList(businessId);
            detailInfo.setAccountDetailList(accountDetailList);
        }
        return detailInfo;
    }
}




